Add a testcase for controls in headerbars
authorMatthias Clasen <mclasen@redhat.com>
Sat, 12 Sep 2020 14:58:07 +0000 (10:58 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sat, 12 Sep 2020 14:58:07 +0000 (10:58 -0400)
This is meant to help with figuring out entry
selection drag issues.

tests/testheaderbar.c
tests/testheadercontrols.ui [new file with mode: 0644]

index b2a63c459bd821e259f8c92953f7d7ccff431631..16d16629bc7508b2985c9564090111d89f57a95f 100644 (file)
@@ -357,6 +357,28 @@ create_stacked_headerbar (GtkApplication *app)
   gtk_window_present (GTK_WINDOW (win));
 }
 
+/* controls */
+static void
+create_controls (GtkApplication *app)
+{
+  GtkBuilder *builder;
+  GtkWidget *win;
+  const char *ui = "tests/testheadercontrols.ui";
+
+  if (!g_file_test (ui, G_FILE_TEST_EXISTS))
+    {
+      g_warning ("Can't find %s", ui);
+      return;
+    }
+
+  builder = gtk_builder_new_from_file (ui);
+
+  win = (GtkWidget *)gtk_builder_get_object (builder, "window");
+  gtk_window_set_application (GTK_WINDOW (win), app);
+
+  gtk_window_present (GTK_WINDOW (win));
+}
+
 /* technorama */
 
 static const char css[] =
@@ -517,6 +539,7 @@ struct {
     { "Fake headerbar", create_fake_headerbar },
     { "Split headerbar", create_split_headerbar },
     { "Stacked headerbar", create_stacked_headerbar },
+    { "Headerbar with controls", create_controls },
     { "Technorama", create_technorama },
 };
 int n_buttons = sizeof (buttons) / sizeof (buttons[0]);
diff --git a/tests/testheadercontrols.ui b/tests/testheadercontrols.ui
new file mode 100644 (file)
index 0000000..4870f8e
--- /dev/null
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <object class="GtkWindow" id="window">
+    <property name="default-width">600</property>
+    <property name="default-height">400</property>
+    <property name="icon-name">preferences-desktop-font</property>
+    <child type="titlebar">
+      <object class="GtkHeaderBar" id="main-header">
+        <property name="hexpand">1</property>
+        <child type="start">
+          <object class="GtkBox">
+            <child>
+              <object class="GtkButton">
+                <property name="label">Yes!</property>
+                <property name="valign">center</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkCheckButton">
+                <property name="label">Check</property>
+                <property name="valign">center</property>
+              </object>
+            </child>
+          </object>
+        </child>
+        <child type="title">
+          <object class="GtkEntry">
+            <property name="valign">center</property>
+            <property name="text">abcdef</property>
+          </object>
+        </child>
+        <child type="end">
+          <object class="GtkBox">
+            <child>
+              <object class="GtkScale">
+                <property name="draw-value">0</property>
+                <property name="width-request">100</property>
+                <property name="adjustment">
+                  <object class="GtkAdjustment">
+                    <property name="lower">0</property>
+                    <property name="upper">100</property>
+                    <property name="value">33</property>
+                  </object>
+                </property>
+              </object>
+            </child>
+          </object>
+        </child>
+      </object>
+    </child>
+  </object>
+</interface>